home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mission 3
/
Mission 3.zip
/
Mission 3.iso
/
zugabe
/
va45
/
visual45
/
gwva_sys.mac
< prev
next >
Wrap
Text File
|
1998-08-22
|
12KB
|
557 lines
*-----------------------------------------------------------------------*
* Macros Custom Visual Assembleur *
*-----------------------------------------------------------------------*
;--------- MACROS DE BASE ----------
save: macro ; save.w d0-d1
ifc '\0','W'
fail ; macro 'save' : l'extension en minuscule
exitm
endc
ifc '\0','L'
fail ; macro 'save' : l'extension en minuscule
exitm
endc
ifeq \?1-2
move.\0 \1,-(sp)
else
movem.\0 \1,-(sp)
endc
endm
load: macro ; load.w d0-d1
ifc '\0','W'
fail ; macro 'load' : l'extension en minuscule
exitm
endc
ifc '\0','L'
fail ; macro 'load' : l'extension en minuscule
exitm
endc
ifeq \?1-2
move.\0 (sp)+,\1
else
movem.\0 (sp)+,\1
endc
endm
appel: macro trap,numéro,actualisation ; appel dos,2,4
move.w #\2,-(sp)
trap #\1
ifle \3-8
addq.w #\3,sp ; on peut faire l'addition sur un .w car
else
add.w #\3,sp ; c'est automatiquement étendu
endc
endm
;--------- MACROS CHAINES DE CARACTERES ----------
COPY_STRING: macro source,dest ; d0.b end char COPY_STRING a0,a1
.\@ccp: move.b (\1)+,(\2)+
cmp.b -1(\1),d0
bne.s .\@ccp
endm
COPY_STRING_0: macro source,dest ; COPY_STRING_0 a0,a1
.\@ccp: move.b (\1)+,(\2)+
bne.s .\@ccp
endm
STOP_ON_0 macro source ; STOP_ON_0 a0 en sortie (source) pointe sur le 0
.\@sch: tst.b (\1)+
bne.s .\@sch
lea -1(\1),\1
endm
;--------- MACROS DE SYNCHRONISATION SYSTEME ----------
SYNCHRO_GEM: macro
\@wait_nul: appel dos,c_conis,2 ; teste du buffer ...
tst.w d0
beq.s \@the_end ; pas de touche en buffer ?
CRAWCIN
bra.s \@wait_nul
\@the_end: VSYNC
endm
;--------- MACROS EVOLUEES LIEES A LA SOURIS ----------
MOUSEOFF: macro
pea GWVA_APP_OBJ_MACRO_MOUSE_INHIBE
move.w #1-1,-(sp)
appel xbios,ikbdws,8
DATA
ifnd GWVA_APP_OBJ_MACRO_MOUSE_INHIBE
GWVA_APP_OBJ_MACRO_MOUSE_INHIBE: dc.b $12
endc
even
TEXT
endm
MOUSEON: macro
pea GWVA_APP_OBJ_MACRO_MOUSE_DEFAULT
move.w #2-1,-(sp)
appel xbios,ikbdws,8
DATA
ifnd GWVA_APP_OBJ_MACRO_MOUSE_DEFAULT
GWVA_APP_OBJ_MACRO_MOUSE_DEFAULT: dc.b $80,$01
endc
TEXT
endm
;--------- MACROS EVOLUEES LIEES A L'ECRAN ----------
RESOLUT: macro video_mode_falcon,video_mode_compatible,physique,logique ; video_mode_compatible=0 : ST / video_mode_compatible=3:FALC
; RESOLUT #$120,#3,#screen1,#screen2
move.w \1,-(sp)
move.w \2,-(sp)
move.l \3,-(sp)
move.l \4,-(sp)
appel xbios,vsetscreen,14
VSYNC
endm
RESERVE_SCREENS: macro nb_ecrans,resolut ; RESERVE_SCREENS 3,res64048016
; + les constantes : x_max_p,y_max_p,nb_bits_per_pix
move.l #screens,d0
and.l #$ffffff00,d0
add.l #$100,d0
move.l d0,a0
lea ecrans,a1
move #\1-1,d0
.raz_screens: move.l a0,(a1)+
move.l #x_max_p*y_max_p*nb_bits_per_pix/8/4,d1
.raz_screen: clr.l (a0)+
subq.l #1,d1
bne.s .raz_screen
dbf d0,.raz_screens
move.l ecran,save_ad_ecr
RESOLUT #-1
and #$1ff,d0
move d0,save_mode
move #\2,d1
btst #5,d0
bne.s .pal_modus
bclr #5,d1
.pal_modus: btst #4,d0 ; tv
bne.s .vga_modus
bclr #4,d1 ; tv
bchg #8,d1 ; vertical mode
.vga_modus:
ifne (\2-res32020016)
RESOLUT d1,#3,ecrans,ecrans
else
RESOLUT d1,#0,ecrans,ecrans
endc
BSS
save_mode: ds.w 1
save_ad_ecr: ds.l 1
ecrans: ds.l \1
screens: ds.l \1*x_max_p*y_max_p*nb_bits_per_pix/8/4
ds.b 256
TEXT
endm
CHANGE_RESOLUT: macro resolut ; CAHNGE_RESOLUT res64048016
move.l ecrans,a0
move.l #x_max_p*y_max_p*nb_bits_per_pix/8/4,d1
.raz_screen: clr.l (a0)+
subq.l #1,d1
bne.s .raz_screen
move.l ecran,save_ad_ecr
RESOLUT #-1
and #$1ff,d0
move d0,save_mode
move #\1,d1
btst #5,d0
bne.s .pal_modus
bclr #5,d1
.pal_modus: btst #4,d0 ; tv
bne.s .vga_modus
bclr #4,d1 ; tv
bchg #8,d1 ; vertical mode
.vga_modus:
ifne (\1-res32020016)
RESOLUT d1,#3,ecrans,ecrans
else
RESOLUT d1,#0,ecrans,ecrans
endc
endm
RESTORE_SCREENS: macro
RESOLUT save_mode,#3,save_ad_ecr,save_ad_ecr
endm
COLOR256: macro color_0 ; COLOR256 #$FF00FF00
ifnd FLG_INHIBE_COLOR
move.l \1,palette256
endc
endm
COLOR: macro color_0 ; COLOR #$0777
ifnd FLG_INHIBE_COLOR
move.w \1,palette
endc
endm
;--------- MACROS LIEES AU ZILOG (PORT SERIE)----------
ZILOGR: macro registre,byte,canal
ifc 'A','\3'
move.b \1,zilog8530A
move.b zilog8530A,\2
else
move.b \1,zilog8530B
move.b zilog8530B,\2
endc
endm
ZILOGW: macro registre,byte,canal
ifc 'A','\3'
move.b \1,zilog8530A
move.b \2,zilog8530A
else
move.b \1,zilog8530B
move.b \2,zilog8530B
endc
endm
*-----------------------------------------------------------------------------*
; MACROS SYSTEME
CRAWCIN: macro
appel dos,c_rawcin,2
endm
CCONWS: macro string ; lea ma_string,a0 CCONWS (a0)
pea \1
appel dos,c_conws,6
endm
SUPEXEC: macro ptr_routine ; lea ma_routine,a0 SUPEXEC (a0)
pea \1
appel xbios,supexec,6
endm
VSYNC: macro
appel xbios,vsync,2
endm
VSETMODE: macro mode ; VSETMODE #0
move.w \1,-(sp)
appel xbios,vsetmode,4
endm
FATTRIB: macro attr,flag,fname ; FATTRIB #%1,#1,mon_fichier
move.w \1,-(sp)
move.w \2,-(sp)
pea \3
appel dos,f_attrib,10
endm
FDELETE: macro fname ; FDELETE mon_fichier
pea \1
appel dos,f_delete,6
endm
FREAD: macro buf,length,handle ; FREAD #mon_buffer,d0,d7
move.l \1,-(sp)
move.l \2,-(sp)
move.w \3,-(sp)
appel dos,f_read,12
endm
FWRITE: macro buf,count,handle ; FWRITE #mon_buffer,d0,d7
move.l \1,-(sp)
move.l \2,-(sp)
move.w \3,-(sp)
appel dos,f_write,12
endm
FSEEK: macro mode,handle,offset ; FSEEK #0,d7,d0
; mode = begining (0), current (1) end (2)
move.w \1,-(sp)
move.w \2,-(sp)
move.l \3,-(sp)
appel dos,f_seek,10
endm
FCLOSE: macro handle ; FCLOSE d7
move.w \1,-(sp)
appel dos,f_close,4
endm
FSFIRST: macro attribs,fspec ; FSFIRST #%11,ma_recherche
move.w \1,-(sp)
pea \2
appel dos,f_sfirst,8
endm
FSNEXT: macro
appel dos,f_snext,2
endm
DCREATE: macro path ; DCREATE mon_dossier
pea \1
appel dos,d_create,6
endm
DFREE: macro buf,drive ; DFREE #'C'-'A',mon_buffer
move.w \2,-(sp)
pea \1
appel dos,d_free,8
endm
DGETDRV: macro
appel dos,d_getdrv,2
endm
DSETDRV: macro drive ; DSETDRV #'C'-'A'
move \1,-(sp)
appel dos,d_setdrv,4
endm
DGETPATH: macro drive,buf ; DGETPATH #'C'-'A',mon_buffer
move.w \1,-(sp)
pea \2
appel dos,d_getpath,8
endm
DSETPATH: macro path ; DSETPATH mon_path
pea \1
appel dos,d_setpath,6
endm
FSETDTA: macro ndta ; FSETDTA mon_dta
pea \1
appel dos,f_setdta,6
endm
FGETDTA: macro
appel dos,f_getdta,2
endm
MALLOC: macro amount ; MALLOC #ma_taille
move.l \1,-(sp)
appel dos,m_alloc,6
endm
MXALLOC: macro mode,amount (RAM_ST, RAM_TT, RAM_ST_TT, RAM_TT_ST) ; MXALLOC #RAM_TT_ST,#ma_taille
move.w \1,-(sp)
move.l \2,-(sp)
appel dos,m_xalloc,8
endm
MFREE: macro startadr ; MFREE #ma_memoire
move.l \1,-(sp)
appel dos,m_free,6
endm
PEXEC: macro env,cmd,prog,mode ; PEXEC (a0),ma_commande,mon_prg,#0
pea \1
pea \2
pea \3
move.w \4,-(sp)
appel dos,p_exec,16
endm
*-----------------------------------------------------------------------------*
; MACROS SEMI-SYSTEME
SUPER: macro mode ; 0=go super ; 1=get current mode
move.l #\1,-(sp)
appel dos,$20,6
ifne \1-1
move.l d0,GWVA_OLD_SUPERVISOR_STACK
endc
endm
USER: macro
move.l GWVA_OLD_SUPERVISOR_STACK,-(sp)
appel dos,$20,6
endm
FILE_OPEN: macro ; \1=read/write \2=name \3=destination pour le handle
ifeq \1-1 ; 0=lecture,other=write
clr.w -(sp)
pea \2
appel dos,$3c,8 ; file create
move d0,\3
endc
ifeq \1
clr.w -(sp)
pea \2
appel dos,$3d,8 ; file open
move d0,\3
endc
ifeq \1-2
move.w #2,-(sp)
pea \2
appel dos,$3d,8
move d0,\3
endc
endm
*-----------------------------------------------------------------------------*
; MACROS POUR LES OBJETS V.A.
GWVA_PROGRAMMER_ERROR: macro pointeur_chaine
ifd OPT_GWVA_DEBUG_ERROR
lea \1,a6
illegal
endc ; ifd OPT_GWVA_DEBUG_ERROR
endm
GWVA_CHECK_OBJ_HANDLE: macro
ifd OPT_GWVA_DEBUG_ERROR
cmp.w #GWVA_OBJ_CTE_HANDLE_UNDEF,GWVA_OBJ_HANDLE(a0)
bne.s .deja_cree
GWVA_PROGRAMMER_ERROR GWVA_ASCII_ERROR_OBJ_HANDLE
.deja_cree:
endc ; ifd OPT_GWVA_DEBUG_ERROR
endm
_GWVA_CALL_METHOD: macro methode,activation
move.l \1,d4
move.w \2,d5
* bsr GWVA_ROOT_PRG_SEARCH_EXEC_METHOD
endm
_GWVA_CALL_METHODNTEST: macro methode,activation ; pour méthodes devant
GWVA_CALL_METHOD \1,\2 ; renvoyer CONSUMED
cmp.w #GWVA_SEARCH_EXEC_CONSUMED,d6
beq.s .\@no_error
cmp.w #GWVA_SEARCH_EXEC_NO_DEST_FOUND,d6
beq.s .\@no_error
GWVA_PROGRAMMER_ERROR GWVA_ASCII_ERROR_METHOD_CONSUMED
.\@no_error:
endm
_GWVA_CALL_METHOD2: macro methode,activation
move.l \1,d4
move.w \2,d5
* bsr GWVA_ROOT_PRG_SEARCH_EXEC_METHOD
endm
_GWVA_CALL_METHODNTEST2: macro methode,activation ; pour méthodes devant
GWVA_CALL_METHOD \1,\2 ; renvoyer CONSUMED
cmp.w #GWVA_SEARCH_EXEC_CONSUMED,d6
beq.s .\@no_error
cmp.w #GWVA_SEARCH_EXEC_NO_DEST_FOUND,d6
beq.s .\@no_error
GWVA_PROGRAMMER_ERROR GWVA_ASCII_ERROR_METHOD_CONSUMED
.\@no_error:
endm
*-----------------------------------------------------------------------------*
; Sauvegarde du contexte en ajoutant .SAVE a la fin des macro
; GWVA_CALL_METHODxx.SAVE
*---------------*
GWVA_CALL_METHOD4: macro activation,methode
move.w \1,d5
IFNC '\2',''
move.l \2,d4
ENDC
bsr GWVA_ROOT_PRG_SEARCH_AND_EXEC_METHOD
endm
*---------------*
; Appel de méthode d'un objet autre que l'objet courant (class MAX forcément)
GWVA_CALL_METHOD_OTHER_OBJ: macro methode
ifne \#-1
fail ; macro GWVA_CALL_METHOD_OTHER_OBJ ne prend qu'un paramètre : la méthode
exitm
endc
ifc '\0','SAVE'
save.l d3/a3-a6
endc
GWVA_CALL_METHOD4 #GWVA_MODE_CLASS_METHOD_SEARCH_OTHER_OBJ,\1
ifc '\0','SAVE'
load.l d3/a3-a6
endc
endm
*---------------*
; Appel d'une méthode différente de la même classe (cherche à partir de i)
GWVA_CALL_METHOD_DIFF_METH_SAME_CLASS:macro methode
ifne \#-1
fail ; macro GWVA_CALL_METHOD_DIFF_METH_SAME_CLASS ne prend qu'un paramètre : la méthode
exitm
endc
ifc '\0','SAVE'
save.l d3/a3-a6
endc
GWVA_CALL_METHOD4 #GWVA_MODE_CLASS_METHOD_SEARCH_DIFF_METH_SAME_CLASS,\1
ifc '\0','SAVE'
load.l d3/a3-a6
endc
endm
*---------------*
; Appel de la même méthode que courante mais classe i-1 (classe dont on hérite)
GWVA_CALL_METHOD_INHERITED: macro ; pas de paramètre
ifne \#
fail ; macro GWVA_CALL_METHOD_INHERITED ne prend aucun paramètre
exitm
endc
ifc '\0','SAVE'
save.l d3/a3-a6
endc
GWVA_CALL_METHOD4 #GWVA_MODE_CLASS_METHOD_SEARCH_INHERITED
ifc '\0','SAVE'
load.l d3/a3-a6
endc
endm
*---------------*
; Création d'un évènement : recherche d'une routine à activer dans la liste locale
GWVA_EXEC_VISUAL_EVENT: macro methode
ifne \#-1
fail ; macro GWVA_EXEC_VISUAL_EVENT ne prend qu'un paramètre : la méthode
exitm
endc
ifc '\0','SAVE'
save.l d3/a3-a6
endc
GWVA_CALL_METHOD4 #GWVA_MODE_CLASS_METHOD_SEARCH_VISUAL_EVENT,\1
ifc '\0','SAVE'
load.l d3/a3-a6
endc
endm